﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data.OleDb;

namespace DbHelp
{
    public class AccessHelper : DbHelper
    {
        public AccessHelper(string dbFile)
            : this(dbFile, null)
        {

        }

        public AccessHelper(string dbFile, string pwd)
        {
            if (dbFile == null || dbFile == string.Empty)
            {
                throw new NotImplementedException("Access文件为空");
            }
            OleDbConnectionStringBuilder connSb = new OleDbConnectionStringBuilder();
            //connSb.Provider = "Microsoft.ACE.OLEDB.12.0";
            //connSb.DataSource = dbFile;
            //connSb.Add("Persist Security Info", "false");
            connSb.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; " + "Data Source=" + dbFile + ";Persist Security Info=False;";

            base.ProviderFactory = OleDbFactory.Instance;
            base.ConnectionString = connSb.ToString();
        }
    }
}
